package com.karson.service.service;


import com.karson.common.exception.AsmrException;
import com.karson.common.model.StorageConfig;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;


@Service
public class StorageServiceFactory {

    @Resource(name = "minioStorageService")
    private IStorageService minioStorageService;

    @Resource(name = "localStorageService")
    private IStorageService localStorageService;

    /**
     * 根据存储类型获取对应的存储服务
     * @param storageType 存储类型
     * @return 对应的存储服务实例
     */
    public IStorageService getStorageService(String storageType) {
        return switch (storageType) {
            case StorageConfig.MINIO -> minioStorageService;
            case StorageConfig.LOCAL -> localStorageService;
            default -> throw new AsmrException("不支持的存储类型");
        };
    }
}